[libcxx] Fix max_size() across all containers Summary: The `max_size()` method of containers should respect both the allocator's reported `max_size` and the range of the `difference_type`. This patch makes all containers choose the smallest of those two values. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26885 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287729 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/vector b/include/vector index edcb7df..f5bd7d0 100644 --- a/include/vector +++ b/include/vector
@@ -941,7 +941,8 @@ typename vector<_Tp, _Allocator>::size_type vector<_Tp, _Allocator>::max_size() const _NOEXCEPT { - return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()), numeric_limits<size_type>::max() / 2); // end() >= begin(), always + return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()), + numeric_limits<difference_type>::max()); } // Precondition: __new_size > capacity()